<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=\, initial-scale=1.0">
    <title>云文档</title>
</head>
<link rel="stylesheet" href="./css/style.css">
<link rel="stylesheet" href="./css/index.css">
<?php

session_start(); // 开启会话

// 如果用户未登录，则跳转到登录页面
if (!isset($_SESSION['user_id'])) {
    header('Location: login.php'); // 请将登录页面的路径替换为实际的路径
    exit();
}
require 'Database.php';
?>

<body>
    <div id="box">
        <div id="app">
            <div>
                <!-- <hr> -->
                <span>
                    控制台
                </span>
            </div>
            <div>
                <div id="app_lnformation">
                    <div>
                        <div>
                            <img src="<?php echo $_SESSION['avatar_url']?>" width="70">
                            <span>用户名</span>
                            <span>(个人免费版)</span>
                        </div>
                        <div class="information">
                            <span>
                                <!-- <i></i> -->
                                <img src="./img/皇冠.png" width="15">
                                升级账号,开通VIP
                            </span>
                            <span>
                                <a href="#">立即升级-></a>
                            </span>
                        </div>
                        <div class="sidebar">
                            <ul class="icon-list">
                                <li>
                                    <img src="img/icon1.png" alt="账号管理" class="icon" width="25" height="25">
                                    账号管理
                                    <!-- <img src="thumbnail-icon1.png" alt="Icon 1" class="thumbnail-icon"> -->
                                </li>
                                <li onclick="toggleDarkMode()">
                                    <img src="img/icon2.png" alt="夜间模式" class="icon" width="25" height="25">
                                    <!-- <img src="thumbnail-icon2.png" alt="Icon 2" class="thumbnail-icon"> -->
                                    夜间模式

                                </li>
                                <li>
                                    <img src="img/icon3.png" alt="帮助中心" class="icon" width="25" height="25">
                                    帮助中心
                                    <!-- <img src="thumbnail-icon3.png" alt="Icon 3" class="thumbnail-icon"> -->
                                </li>
                            </ul>
                        </div>
                        <div id="sidebar_bottom">
                            <div></div>
                            <div onclick="create()">立即创建</div>
                        </div>
                    </div>
                </div>
                <div id="box_app_lnformations">
                    <div>
                            <div style="background-color: black; color: #fff;">我的桌面</div>
                            <div>共同协作</div>
                    </div>
                    <div style="padding: 0 14px;height: 40px; line-height:50px; display: flex; font-size: 11px;"><div class="box_app_lnformationsis" style="width: 4px; height: 16px;margin-top: 16px; margin-right:10px; border-radius:10px ;">
                    </div>
                    /首页</div>
                    <div id="app_lnformations" >
                        
                    </div>
            </div>
            </div>
        </div>
       

    </div>
</body>
<script src="./js/index.js"></script>

<script src="./js/style.js"></script>
<script>
   var data =  <?php
            $database = new Database();
            echo json_encode($database->getUsersFile(intval($_SESSION['user_id'])),JSON_UNESCAPED_UNICODE);?>

    function isfile() {
        if(true){
            showAlertWithFile("提示","打开失败请联系管理员",false); 
        }
    }
    function create(){
        showAlertWithFile("新建文件", "", true, function(result, fileType, inputValue) {
            if (result) {
                for (let iterator of file_type) {
                    if(iterator.type==fileType){
                        data.push({id:data.length+1,title:inputValue,type:parseInt(fileType),img:iterator.type!=fileType?"img/未知文件.png":iterator.img}); 
                        rendering()
                    }
             
                  }

            } else {
                console.log("User clicked Cancel");
            }
        });

    }
    function Delete(id){

    }
        rendering(data)
    
</script>


</html>